/**
 * @author zhouheng
 * @date 2022年03月04日 17:37
 */

package com.atguigu.gulimall.product.config;

import java.io.IOException;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MyRedissonConfig {

    @Value("${spring.redis.host}")
    private String ipAddr;

    @Bean(destroyMethod="shutdown")
    RedissonClient redisson() throws IOException {
        //1、创建配置
        Config config = new Config();
        config.useSingleServer()
            .setAddress("redis://" + ipAddr + ":6379");
        return Redisson.create(config);
    }

}
